<?php
    namespace app\api\model;
    use think\Model;
    
    class Poetries extends Model
    {
        protected $hidden = ['created_at', 'updated_at'];

        // 关联作者
        public function author(Type $var = null)
        {
            return $this->belongsTo('Poets','poet_id','id');
        }
        //获取标题
        public static function getTitle($id,$limit)
        {
            $request = self::where('poet_id',$id)
                ->field('id,poet_id,title')
                ->paginate($limit);
            return $request ;
        }
        //获取详情
        public static function getDetail($Id){
            $request = self::with('author')->where('id',$Id)->select()[0];
            $request['name'] = $request['author']['name'];
            return $request;
        }
    }